//
//  MXHomeItemDetailTableViewCell.m
//  MXの衣柜
//
//  Created by 马霄 on 15/8/8.
//  Copyright (c) 2015年 霄 马. All rights reserved.
//

#import "MXHomeItemDetailTableViewCell.h"
#import "UIImageView+WebCache.h"

@interface MXHomeItemDetailTableViewCell ()
@property (nonatomic, retain) UILabel *logolb;
@property (nonatomic, retain) UILabel *materiallb;
@property (nonatomic, retain) UILabel *stylelb;
@property (nonatomic, retain) UILabel *itemNumlb;
@property (nonatomic, retain) UILabel *colorlb;
@property (nonatomic, retain) UILabel *seasonlb;
@end
@implementation MXHomeItemDetailTableViewCell
- (void)dealloc
{
    [_logolb release];
    [_materiallb release];
    [_stylelb release];
    [_itemNumlb release];
    [_colorlb release];
    [_seasonlb release];
    
    [_modelS release];
    [_logoLabel release];
    [_materialLabel release];
    [_styleLabel release];
    [_itemNumLabel release];
    [_colorlabel release];
    [_seasonlabel release];
    [_recommendLabel release];
    [_mainImageView release];
    [_describeLabel release];
    [_pricrLabel release];
    [_summarylabel release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {

        
        self.backgroundColor = [UIColor whiteColor];
        
        self.logoLabel = [[[UILabel alloc] init] autorelease];
        self.logoLabel.backgroundColor = [UIColor whiteColor];
        self.logoLabel.textAlignment = NSTextAlignmentRight;
        [self.contentView addSubview:self.logoLabel];
        [self.logoLabel setTextColor:[UIColor blueColor]];
        
        self.materialLabel = [[[UILabel alloc] init] autorelease];
        self.materialLabel.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:self.materialLabel];
        self.materialLabel.textAlignment = NSTextAlignmentRight;
        [self.materialLabel setTextColor:[UIColor blueColor]];

        self.styleLabel = [[[UILabel alloc] init] autorelease];
        self.styleLabel.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:self.styleLabel];
        self.styleLabel.textAlignment = NSTextAlignmentRight;
        [self.styleLabel setTextColor:[UIColor blueColor]];

        self.itemNumLabel = [[[UILabel alloc] init] autorelease];
        self.itemNumLabel.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:self.itemNumLabel];
        self.itemNumLabel.textAlignment = NSTextAlignmentRight;
        [self.itemNumLabel setTextColor:[UIColor blueColor]];

        self.colorlabel = [[[UILabel alloc] init] autorelease];
        self.colorlabel.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:self.colorlabel];
        self.colorlabel.textAlignment = NSTextAlignmentRight;
        [self.colorlabel setTextColor:[UIColor blueColor]];

        self.seasonlabel = [[[UILabel alloc] init] autorelease];
        self.seasonlabel.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:self.seasonlabel];
        self.seasonlabel.text = @"";
        self.seasonlabel.textAlignment = NSTextAlignmentRight;
        [self.seasonlabel setTextColor:[UIColor blueColor]];

// 标题部分
        self.logolb = [[[UILabel alloc] init] autorelease];
        self.logolb.text = @"品牌名称:";
        self.logolb.textAlignment = NSTextAlignmentRight;
        [self.contentView addSubview:self.logolb];

        self.materiallb = [[[UILabel alloc] init] autorelease];
        self.materiallb.text = @"材质:";
        [self.contentView addSubview:self.materiallb];
        self.materiallb.textAlignment = NSTextAlignmentRight;

        
        self.stylelb = [[[UILabel alloc] init] autorelease];
        self.stylelb.text = @"基础风格:";
        [self.contentView addSubview:self.stylelb];
        self.stylelb.textAlignment = NSTextAlignmentRight;

        
        self.itemNumlb = [[[UILabel alloc] init] autorelease];
        self.itemNumlb.text = @"货号:";
        self.itemNumlb.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:self.itemNumlb];
        self.itemNumlb.textAlignment = NSTextAlignmentRight;

        self.colorlb = [[[UILabel alloc] init] autorelease];
        self.colorlb.text = @"款式颜色:";
        [self.contentView addSubview:self.colorlb];
        self.colorlb.textAlignment = NSTextAlignmentRight;

        self.seasonlb = [[[UILabel alloc] init] autorelease];
        self.seasonlb.text = @"适用季节:";
        [self.contentView addSubview:self.seasonlb];
        self.seasonlb.textAlignment = NSTextAlignmentRight;

    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    CGFloat WID = self.contentView.frame.size.width;    
    
    CGFloat logoLabelX = WIDTH / 375 * 100;
    CGFloat logoLabelY = HEIGHT / 667 * 0;
    CGFloat logoLabelW = WID - WIDTH / 375 * (logoLabelX + 50);
    CGFloat logoLabelH = HEIGHT / 667 * 60;
    self.logoLabel.frame = CGRectMake(logoLabelX, logoLabelY, logoLabelW, logoLabelH);

    CGFloat lbX = 0;
    CGFloat lbY = logoLabelY;
    CGFloat lbW = WIDTH / 375 * 100;
    CGFloat lbH = logoLabelH;
    self.logolb.frame =CGRectMake(lbX, lbY, lbW, lbH);
    
    CGFloat materialLabelX = logoLabelX;
    CGFloat materialLabelY = logoLabelH + logoLabelY;
    CGFloat materialLabelW = logoLabelW;
    CGFloat materialLabelH = logoLabelH;
    self.materialLabel.frame = CGRectMake(materialLabelX, materialLabelY, materialLabelW, materialLabelH);
    self.materiallb.frame = CGRectMake(lbX, materialLabelY, lbW, lbH);
    
    CGFloat styleLabelX = logoLabelX;
    CGFloat styleLabelY = materialLabelH + materialLabelY;
    CGFloat styleLabelW = logoLabelW;
    CGFloat styleLabelH = logoLabelH;
    self.styleLabel.frame = CGRectMake(styleLabelX, styleLabelY, styleLabelW, styleLabelH);
    self.stylelb.frame = CGRectMake(lbX, styleLabelY, lbW, lbH);
    
    CGFloat itemNumLabelX = logoLabelX;
    CGFloat itemNumLabelY = styleLabelH + styleLabelY;
    CGFloat itemNumLabelW = logoLabelW;
    CGFloat itemNumLabelH = logoLabelH;
    self.itemNumLabel.frame = CGRectMake(itemNumLabelX, itemNumLabelY, itemNumLabelW, itemNumLabelH);
    self.itemNumlb.frame = CGRectMake(lbX, itemNumLabelY, lbW, lbH);
    
    CGFloat colorlabelX = logoLabelX;
    CGFloat colorlabelY = itemNumLabelH + itemNumLabelY;
    CGFloat colorlabelW = logoLabelW;
    CGFloat colorlabelH = logoLabelH;
    self.colorlabel.frame = CGRectMake(colorlabelX, colorlabelY, colorlabelW, colorlabelH);
    self.colorlb.frame = CGRectMake(lbX, colorlabelY, lbW, lbH);
    
    CGFloat seasonlabelX = logoLabelX;
    CGFloat seasonlabelY = colorlabelH + colorlabelY;
    CGFloat seasonlabelW = logoLabelW;
    CGFloat seasonlabelH = logoLabelH;
    self.seasonlabel.frame = CGRectMake(seasonlabelX, seasonlabelY, seasonlabelW, seasonlabelH);
    self.seasonlb.frame = CGRectMake(lbX, seasonlabelY, lbW, lbH);
        
    
}
-(void)GetInfo:(MXHomeItemDetailModel *)model
{
    if (_modelS != model) {
        [_modelS release];
        _modelS = [model retain];
    }
    self.logoLabel.text = model.brand;

    self.materialLabel.text = model.material;
    
    self.styleLabel.text = model.style;
    
    self.itemNumLabel.text = model.num_iid;
    
    self.colorlabel.text = model.color;
    
    self.seasonlabel.text = model.season;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (void)backAction
{
    
}
@end
